package com.aaa.tmr.service.impl;

import com.aaa.tmr.service.CommonFileService;
import com.aaa.tmr.util.OssProperty;
import com.aaa.tmr.util.OssUtil;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@Service
public class CommonFileServiceImpl implements CommonFileService{

    @Resource
    private OssProperty ossProperty;

    @Override
    public Map uploadFile(MultipartFile file, String savePath) {
        String path = OssUtil.uploadFile(file, savePath, ossProperty);
        Map returnMap = new HashMap();
        returnMap.put("fileName",file.getOriginalFilename());
        returnMap.put("filePath",ossProperty.getUrl() + path);
        return returnMap;
    }
}
